<template>
  <el-container class="main_con">
    <div class="filter_con ds_block">
      <!-- <div class="button_area">
        <el-button v-has size="small" type="primary" @click="addHandle"></el-button>
      </div> -->
      <!--    <div class="filter_area">
        <el-input size="small" v-model="params.name" class="serach_input mr_15 mt_15" placeholder="检索标题,微信号,主播昵称"></el-input>
        <label class="mr_15 ml_15">主播间状态</label>
        <el-select clearable size="small" v-model="params.status" placeholder="请选择">
          <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"></el-option>
        </el-select>
        <label class="mr_15 ml_15">直播时间</label>
        <date-picker size="small" @change="gettime" class="mr_15 mt_15"></date-picker>
        <el-button size="small" @click="search">搜索</el-button>
      </div> -->
    </div>
    <div class="list_con">
      <el-table @selection-change="SelectHadnle" :data="list" element-loading-text fit highlight-current-row class="main-loading">
        <el-table-column prop="id" label="ID" width="100px"></el-table-column>
        <el-table-column label="商品">
          <template slot-scope="scope">
            <div class="proImg u-flex" v-if="scope.row.desc && scope.row.desc.msg == '采集成功'">
              <!-- <vimage style="width: 40px; height: 40px;margin-right:10px;" :src="scope.row.master" fit="fit"></vimage> -->
              <vimage style="width: 40px; height: 40px;margin-right:10px;" :src="scope.row.desc.data.master"></vimage>
              <span style="flex: 1;">{{ scope.row.desc.data.name }}</span>
            </div>
            <div v-else>{{ scope.row.desc.msg }}</div>
          </template>
        </el-table-column>
        <el-table-column label="采集时间" prop="create_time"></el-table-column>
    <!--    <el-table-column label="操作" width="280px">
          <template slot-scope="scope">
            <el-button v-has style="margin-left: 10px;" type="text" >编辑</el-button>
          </template>
        </el-table-column> -->
      </el-table>
      <div class="table_footer">
        <!--  <el-button size="medium">批量删除
        </el-button>-->
        <el-pagination
          @current-change="ChangeCurrent"
          class="pages"
          background
          layout="prev, pager, next"
          :total="total"
          :page-size="params.size"
          :page-count="params.page"
          hide-on-single-page
        ></el-pagination>
      </div>
    </div>
    <!-- <el-drawer class="w_80" title="编辑管理员" :visible.sync="drawer" :direction="direction">
      <edituser @on-close="beClose" :uid='user_id' :user_type="user_type"></edituser>
    </el-drawer>-->
    <el-dialog title="直播间分享码" :visible.sync="showQrcode" width="500px" class="dialog_box">
      <div class="u-flex" style="width:100%;justify-content: center;"><img style="width: 200px;" :src="Qrcode" /></div>
    </el-dialog>
  </el-container>
</template>

<script>
import {mapGetters} from 'vuex';
import {getscrapyLogList} from '@/api/mall/scrapy';
import DatePicker from '@/components/DatePicker/index';
import {fitter_keyword} from '@/utils/index';
export default {
  data() {
    return {
      showQrcode: false,
      Qrcode: '',
      params: {
        status: '',
        page: 1,
        size: 10
      },
      paramsdf: {},
      options: [
        {
          value: 101,
          label: '直播中'
        },
        {
          value: 102,
          label: '未开始'
        },
        {
          value: 103,
          label: '已结束'
        },
        {
          value: 104,
          label: '禁播'
        },
        {
          value: 105,
          label: '暂停'
        },
        {
          value: 106,
          label: '异常'
        },
        {
          value: 107,
          label: '已过期'
        }
      ],

      total: 0,
      listLoading: true,
      list: [],
      drawer: false,
      direction: 'rtl',
      user_id: '',
      user_type: 'add',
      selectionData: [],
      url: ''
    };
  },
  components: {
    DatePicker
  },
  computed: {
    ...mapGetters(['allroleslist'])
  },
  mounted() {
    this.getlist();
  },
  filters: {
    statustxt(status) {
      switch (status) {
        case 101:
          return '直播中';
          break;
        case 102:
          return '未开始';
          break;
        case 103:
          return '已结束';
          break;
        case 104:
          return '禁播';
          break;
        case 105:
          return '暂停';
          break;
        case 106:
          return '异常';
          break;
        case 107:
          return '已过期';
          break;
        default:
          return '-';
          break;
      }
    }
  },
  methods: {
    getQrcode(id) {
      this.Qrcode = '';
      let data = {
        id: id
      };
      getQrcode(data).then(res => {
        this.Qrcode = res.msg.cdnUrl;
        this.showQrcode = true;
      });
    },
    changecomment() {
      console.log(a, b);
      let data = {
        status: a,
        id: b.room_id
      };
      // updateFeedPublic(data).then(res => {
      //   this.getlist();
      // });
    },
    changef(a, b) {
      console.log(a, b);
      let data = {
        status: a,
        id: b.room_id
      };
      updateFeedPublic(data).then(res => {
        this.getlist();
      });
    },
    doCopy(data) {
      this.$copyText(data).then(
        res => {
          //this.$alert('复制成功');
          this.$message({
            message: '复制成功',
            type: 'success',
            duration: 2000
          });
          // data.visible = false;
        },
        error => {
          this.$alert('无法复制');
        }
      );
    },
    search() {
      this.paramsdf = fitter_keyword(this.params);
      this.getlist();
    },
    //启用，禁用
    EnableHandle(id) {
      let _this = this;
      this.$confirm('确认停止当前活动？')
        .then(_ => {
          let params = {id: id};
          stopgroup(params).then(res => {
            _this.getlist();
          });
        })
        .catch(_ => {});
    },
    //选择
    SelectHadnle(selection) {
      this.selectionData = selection;
    },
    //删除
    handleClose(id) {
      let _this = this;
      this.$confirm('确认删除？')
        .then(_ => {
          let data = {
            id: id
          };
          delliver(data).then(res => {
            this.$message.success('删除成功');
            _this.getlist();
          });
        })
        .catch(_ => {});
    },
    //新增
    addHandle() {
      this.$router.push('/liver/item');
    },
    //编辑
    EditHandle(id) {
      this.$router.push({path: '/liver/item', query: {id: id}});
    },
    operateHandle(id) {
      this.$router.push({path: '/liver/operate', query: {id: id}});
    },
    //编辑完成
    beClose() {
      (this.drawer = false), this.getlist();
    },
    //获取列表
    getlist() {
      this.listLoading = true;
      let data = fitter_keyword(this.params);
      getscrapyLogList(data).then(res => {
        var jsondata = res.msg;
        this.list = jsondata.data;
        this.total = jsondata.total;
        // this.list = response.data.items
        this.listLoading = false;
      });
    },
    //获取时间
    gettime(value) {
      this.params.start_time = value[0];
      this.params.end_time = value[1];
    },
    //切换页码
    ChangeCurrent(page) {
      this.params.page = page;
      this.getlist();
    },
    syncHandle() {
      syncRoom({}).then(res => {
        this.getlist();
      });
    }
  }
};
</script>

<style lang="scss" scoped></style>
